﻿$(document).ready(function (e) {
    var scrllTopz;
    var scrllTopz_prev = 0;
    var marinposti = [];
    var setInterTime;
    var setInterTime2;
	var windowwidth=$(window).width();
    $(window).scroll(function () {
			windowwidth=$(window).width();
			scrllTopz = $(window).scrollTop(); /////获取scrollTop///////////
			scrolBackmarin(); //////版块1///////
			scrolBackmarin2(); /////版块2///////
			//scrolBackmarin3(); /////版块3///////
			scrolBackmarin4(); /////版块4///////
		

    });
    /////1/////////
    $(".phonePicBntxa").width($(".phonePicBntxa a").width() * $(".phonePicBntxa a").length);
    var curDqinaindx = 0;
    $(".phoneBoxEffct img").eq(0).css("left", 0);
    $(".phonePicBntxa a").click(function () {
        $(".phoneBoxEffct img").eq(curDqinaindx).stop().css("left", 0).animate({ left: "-100%" });
        curDqinaindx = $(".phonePicBntxa a").index(this);
        $(".phoneBoxEffct img").eq(curDqinaindx).stop().css("left", "100%").animate({ left: 0 });
    })

    $(window).resize(function () {
        resirzScrolsber();
    })
    resirzScrolsber();
    function resirzScrolsber() {
        if ($(".phonePicBntxa").width() > $(".phonePicBntx").width()) {
            $(".phonePicBntx").addClass("phoneScrolBar");
        } else {
            $(".phonePicBntx").removeClass("phoneScrolBar");
        }
		
		/*if($(window).width()>=1000){
			var widnowhet=($(window).height()-$(".advantageA").height())/2;
			$(".WebServiceYS_ul li").height(widnowhet);
		}else{
			$(".WebServiceYS_ul li").removeAttr("style");
		}*/
    }


    function scrolBackmarin() {
        var minscroTp = Math.min(scrllTopz, 947);
        $(".backImgY4").css({ marginTop: -minscroTp })
        $(".backImgY3").css({ marginTop: -minscroTp * 0.7 })
        $(".backImgY2").css({ marginTop: -minscroTp * 0.5 })
        $(".backImgY1").css({ marginTop: -minscroTp * 0.3 })
        $(".serveAppIPCback").css({ right: -scrllTopz * 0.8 });
        if (scrllTopz < 20) {
            if (!$(".serveApp1nav").hasClass("boldns")) {
                DIyipinXoipdd();
                $(".serveApp1nav").addClass("boldns")
            }
        }
        if (scrllTopz > 200) {
            $(".serveApp1nav").removeClass("boldns")
        }
    }
    function DIyipinXoipdd() {
        clearInterval(setInterTime2);
        $(".serveApp1nav img").css({ opacity: 0, top: -30 });
        var jishuNUm = 0;
        setInterTime2 = setInterval(function () {

            $(".serveApp1nav img").eq(jishuNUm).animate({ top: 0, opacity: 1 }, 300, "easeOutBack")
            jishuNUm++;
            if (jishuNUm > 3) {
                clearInterval(setInterTime2);
            }
        }, 300)



    }
	
	
	
	 quehuanIntUl(5);
            $(".DtiasNv a").click(function () {
                var intsx = $(".DtiasNv a").index(this);
                quehuanIntUl(intsx);
            })


            function quehuanIntUl(ins) {
                $(".serveAppBk5").hide();
                $(".serveAppBk5").eq(ins).show();
                $(".DtiasNv a").removeClass("curensQhs").eq(ins).addClass("curensQhs");
            }
	

    /////1***///////// 
    /////2/////////
    function scrolBackmarin2() {
        var minscroTp = Math.min(Math.abs(790 - scrllTopz), 280) / 2;
        $(".serveAppBk2H .back").css({ width: 540 - minscroTp, height: 177 - minscroTp / 540 * 177, left: minscroTp / 2, top: minscroTp / 540 * 177 / 2 });
        $(".MterbottomMtl2img").css({ left: scrllTopz * 0.05 - 5000 });
        $(".ImgbottomMterl2A").css({ left: -scrllTopz * 3 });
        $(".ImgbottomMterl2B").css({ left: -scrllTopz * 5 });
        var windowWdt = $(window).width();
        if (windowWdt >= 1000) {
			if($(".serveAppBk2").length<1) return;
            var minscroTpa = Math.max($(".serveAppBk2").offset().top - scrllTopz, 0) / 2;
			$(".serveAppBk2 .serveAppBk2H").css({top:-minscroTpa/3});
			$(".serveAppBk2 .serveAppBk2_btn").css({top:-minscroTpa/6});
			$(".serveAppBk2 .serveAppBk2_Pic_box").css({top:-minscroTpa/7});
			
            $(".serveAppBk2_Picul li").each(function (index, element) {
                $(this).css({ left: (index % 5 - 2) * minscroTpa / (1 + Math.floor(index / 5)), opacity: Math.abs(300 - Math.min(Math.abs((index % 5 - 2) * minscroTpa / (1 + Math.floor(index / 5))), 300)) / 300});
            });
        } else {
            $(".serveAppBk2_Picul li").css({ left: 0 });
			$(".serveAppBk2 .serveAppBk2H").css({top:0});
			$(".serveAppBk2 .serveAppBk2_btn").css({top:0});
			$(".serveAppBk2 .serveAppBk2_Pic_box").css({top:0});
			$(".serveAppBk2_Picul li").css("opacity",1);
        }

    }
    /////2***/////////
    /////3/////////
    function scrolBackmarin3() {
        var windowWdt = $(window).width();
        $(".serveAppBk3_Title .mask").css("right", -scrllTopz);
		var sctoshuzhi=$(".serveAppBk3_Cont1").offset().top;
		/*if(sctoshuzhi-scrllTopz>-100 && sctoshuzhi-scrllTopz>-600){
			$(".serveAppBk3_ul li").each(function (index, element) {
				var indexsd=$(this).parent().find("li").index(this);
				var thisobj=$(this);
				setTimeout(function(){
					thisobj.stop().animate({left:0,opacity:1},300,"easeOutCubic");
				},1000+indexsd*50)
				
			});
		}*/
		
		if(sctoshuzhi-scrllTopz>1000 || sctoshuzhi-scrllTopz<-600){
			$(".serveAppBk3_ul li").stop().css({left:300,opacity:0});	
		}
		
		if(windowwidth>1000){
			var scrllTleft=Math.max($(".serveAppBk3").offset().top-scrllTopz,0);
			$(".serveAppBk3_Title").css({top:-scrllTleft/5});
			$(".serveAppBk3_p").css({top:-scrllTleft/7});
			$(".serveAppBk3_Cont").css({top:-scrllTleft/9});
			$(".serveAppBk3_ul li").each(function (index, element) {
            //var thisOfst = $(this).offset().top;
           // var leftZhi = Math.max($(this).offset().top - 500 - scrllTopz, 0);
           	 $(this).css({ left: scrllTleft*index/5, opacity:1-scrllTleft/500*index});
       		 });
		}else{
			$(".serveAppBk3_Title").css({top:0});
			$(".serveAppBk3_p").css({top:0});
			$(".serveAppBk3_Cont").css({top:0});
			$(".serveAppBk3_ul li").css({left:0,opacity:1});
		}
		
        

    }
    /////3***///////// 
    /////4/////////
    setCladdss();
    startBackmarin4();
    function startBackmarin4() {
        scrllTopz = $(window).scrollTop();
        $(".serveAppBk4_picms").each(function (index, element) {
            if (index != 0) {
                marinposti.push({ x: $(".serveAppBk4_picms .img1").eq(index - 1).offset().left - $(".serveAppBk4_picms .img1").eq(index).offset().left, y: $(".serveAppBk4_picms .img1").eq(index - 1).offset().top - $(".serveAppBk4_picms .img1").eq(index).offset().top });
            } else {
                marinposti.push({ x: 0, y: 0 });
            }
        });
        SETpoitinss(); //设置原始位置///	
    }

    function SETpoitinss() {
        $(".serveAppBk4_picms").each(function (index, element) {
           // $(this).find(".img1,.img2,span").css({ left: marinposti[index].x, top: marinposti[index].y });
        });
        //$(".serveAppBk4_picms").css("opacity", 0);
       // $(".serveAppBk4_picList").css("opacity", 1)
        //$(".serveAppBk4").addClass("botlsdap");

    }


    function scrolBackmarin4() {
        var huoquOfst = $(".serveAppBk4").offset().top-300;
        if (scrllTopz < huoquOfst - 500) {
            SETpoitinss();
            clearInterval(setInterTime);

        }
		if(windowwidth>1000){
			var serveApas=Math.max($(".serveAppBk4").offset().top-scrllTopz,0);
			$(".serveAppBk4_Scrollapp .Title").css({top:-serveApas/5});
			$(".serveAppBk4_Scrollapp .serveAppBk4_p").css({top:-serveApas/7});
			$(".serveAppBk4_Scrollapp .serveAppBk2_btn").css({top:-serveApas/9});
			$(".serveAppBk4_Scrollapp .serveAppBk4_picList").css({top:-serveApas/11});
		}else{
			$(".serveAppBk4_Scrollapp .Title").css({top:0});
			$(".serveAppBk4_Scrollapp .serveAppBk4_p").css({top:0});
			$(".serveAppBk4_Scrollapp .serveAppBk2_btn").css({top:0});
			$(".serveAppBk4_Scrollapp .serveAppBk4_picList").css({top:0});
		}
		
		

        if (scrllTopz > huoquOfst && $(".serveAppBk4").hasClass("botlsdap")) {
            var i = 0;
            $(".serveAppBk4").removeClass("botlsdap");
			//$(".serveAppBk4_picms").
           /* $(".serveAppBk4_picList").animate({ opacity: 1 }, 300, function () {
                setInterTime = setInterval(function () {
                    $(".serveAppBk4_picms").eq(i).animate({ opacity: 1 });
                    $(".serveAppBk4_picms").eq(i).find("img,span").stop().animate({ left: 0, top: 0 }, 200, "easeInOutCubic");
                    i++;
                    if (i > marinposti.length + 1) {
                        clearInterval(setInterTime);
                    }
                }, 300)

            });*/
        }


    }
    /////4***///////// 


});

function setCladdss() {
    $(".serveAppBk4_picms").each(function (index, element) {
        if (index > 4) {
            $(this).addClass("picms");
        }
    });
}